#!/bin/bash
IMAGEFILE=""

flashonly()
{

if [ -d /work/packages ];then
	rm -rf /work/packages
fi
	mkdir -p /work/packages

#cp out/target/product/sf3gr_telit_he922/sf3gr_telit_he922-flashfiles-eng.archermind.zip /work/packages/
cp ${IMAGEFILE} /work/packages/
cd /work/packages/
unzip *.zip
cp mvconfigs/mvconfig_smp_profiling_signed.fls mvconfig_smp_signed.fls
downloadtool -c1 --erase-mode 0 --library /work/project/austonio/FLASHTOOL_E2/libDownloadTool.so *.fls

}

compileandroid()
{
#cd kernel/gmin-quilt-representation/
#./sofia-git-build.sh
#cd ../..
#rm device/intel/sofia3g-kernel/i386 -r
#cp kernel/gmin-quilt-representation/i386 device/intel/sofia3g-kernel/ -r
#make flashfiles -j6
make flashfiles -j8 BUILD_OSAS=0
}

usage(){
cat <<EOF
Usage
	comp_flash flash/compile
EOF
exit
}

if [ $1 = "compile" ];then
	compileandroid
elif [ $1 = "flash" ];then
	IMAGEFILE="$2"
	flashonly
else
	usage
fi
